package cn.moningxi.controller;

import cn.moningxi.bean.CustomerInfomation;
import cn.moningxi.bean.OComment;
import cn.moningxi.service.OCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class OCommentController {
    @Autowired
    OCommentService oCommentService;

    /**
     * 根据用户id查询用户评论
     *
     * @param mv
     * @param request
     * @return
     */
    @RequestMapping("/cntApi/commentGoods")
    public ModelAndView getCommentByUid(ModelAndView mv, HttpServletRequest request) {
        CustomerInfomation onlineUser = (CustomerInfomation) request.getSession().getAttribute("onlineUser");
        List<OComment> oCommentList = oCommentService.getCommentByUid(onlineUser.getCustomerId());
        mv.addObject("comments", oCommentList);
        mv.setViewName("business/person/comment");
        return mv;
    }
}
